    //
//  CoverViewController.m
//  Drivers
//
//  Created by Hunk on 10-11-16.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CoverViewController.h"
#import "StartExamViewController.h"
#import "ReviewViewController.h"
#import "StrengtheningMemoryViewController.h"
#import "SettingViewController.h"
//#import "MoreViewController.h"
#import "AboutViewController.h"

@implementation CoverViewController
@synthesize m_pStartExamButton;
@synthesize m_pCheckWrongQuestionsButton;
@synthesize m_pStrengtheningMemoryButton;
@synthesize m_pSettingButton;
@synthesize m_pMoreButton;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
{
    [super viewDidLoad];
	
	self.navigationController.visibleViewController.title = @"驾照模拟考试";
    self.navigationController.navigationBar.tintColor = TINT_COLOR;
    
    UIImage *image = [UIImage imageNamed:@"cell_background.png"];
    [_bgImageView setImage:[image stretchableImageWithLeftCapWidth:5 topCapHeight:5]];
    
    [UIView viewLayerCorner:m_pStartExamButton];
    [UIView viewLayerCorner:m_pCheckWrongQuestionsButton];
    [UIView viewLayerCorner:m_pStrengtheningMemoryButton];
    [UIView viewLayerCorner:m_pSettingButton];
    [UIView viewLayerCorner:m_pMoreButton];
}

#pragma mark -
#pragma mark Start exam button handle
- (IBAction)startExamButtonHandle:(id)sender
{	
	// Add 返回 bar button item
	UIBarButtonItem* backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"返回" 
																  style:UIBarButtonItemStyleBordered 
																 target:nil 
																 action:nil] autorelease];

	self.navigationItem.backBarButtonItem = backBarButtonItem;
	
	// Go to start exam view
	StartExamViewController* startExamViewController = [[StartExamViewController alloc] initWithNibName:@"StartExamViewController" bundle:nil];	
	
	[self.navigationController pushViewController:startExamViewController animated:YES];
	
	[startExamViewController release];
	startExamViewController = nil;
}

#pragma mark -
#pragma mark Check wrong questions button handle
- (IBAction)checkWrongQuestionsButtonHandle:(id)sender
{
	// Add 返回 bar button item
	UIBarButtonItem* backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"返回" 
																		   style:UIBarButtonItemStyleBordered 
																		  target:nil 
																		  action:nil] autorelease];
	
	self.navigationItem.backBarButtonItem = backBarButtonItem;
	
	// Go to review view
	ReviewViewController* reviewViewController = [[ReviewViewController alloc] initWithNibName:@"ReviewViewController" bundle:nil];	
	
	[self.navigationController pushViewController:reviewViewController animated:YES];
	
	[reviewViewController release];
	reviewViewController = nil;
}

#pragma mark -
#pragma mark Strengthening memory button handle
- (IBAction)strengtheningMemoryButtonHandle:(id)sender
{
	// Add 返回 bar button item
	UIBarButtonItem* backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"返回" 
																		   style:UIBarButtonItemStyleBordered 
																		  target:nil 
																		  action:nil] autorelease];
	
	self.navigationItem.backBarButtonItem = backBarButtonItem;
	
	// Go to strengthening memory view
	StrengtheningMemoryViewController* strengtheningMemoryViewController = [[StrengtheningMemoryViewController alloc] initWithNibName:@"StrengtheningMemoryViewController" bundle:nil];	
	
	[self.navigationController pushViewController:strengtheningMemoryViewController animated:YES];
	
	[strengtheningMemoryViewController release];
	strengtheningMemoryViewController = nil;
}

#pragma mark -
#pragma mark Setting button handle
- (IBAction)settingButtonHandle:(id)sender
{
	// Add 返回 bar button item
	UIBarButtonItem* backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"返回" 
																		   style:UIBarButtonItemStyleBordered 
																		  target:nil 
																		  action:nil] autorelease];
	
	self.navigationItem.backBarButtonItem = backBarButtonItem;
	
	// Go to setting  view
	SettingViewController* settingViewController = [[SettingViewController alloc] initWithNibName:@"SettingViewController" bundle:nil];	
	
	[self.navigationController pushViewController:settingViewController animated:YES];
	
	[settingViewController release];
	settingViewController = nil;
}

#pragma mark -
#pragma mark More button handle
- (IBAction)moreButtonHandle:(id)sender
{
	// Add 返回 bar button item
	UIBarButtonItem* backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"返回" 
																		   style:UIBarButtonItemStyleBordered 
																		  target:nil 
																		  action:nil] autorelease];
	
	self.navigationItem.backBarButtonItem = backBarButtonItem;
	
	// Go to more  view
    AboutViewController *aboutViewController = [[AboutViewController alloc] init];
    [self.navigationController pushViewController:aboutViewController animated:YES];
    [aboutViewController release];
    
//	MoreViewController* moreViewController = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];	
//	
//	[self.navigationController pushViewController:moreViewController animated:YES];
//	
//	[moreViewController release];
//	moreViewController = nil;
}

#pragma mark -
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
